<template>
	<view class="bottom">
		<view class="div"></view>
		<uvtabbar :value="value" :fixed="true" inactiveColor="#999999" activeColor="#FF7133" :placeholder="false"
			:safeAreaInsetBottom="true">
			<uvtabbarItem v-for="(item,key) in list" :key="key" :text="item.text" :name="item.text"
				@click="toUrl(item)">
				<image :class="[item.class]" slot="inactive-icon" :src="item.img"></image>
				<image :class="[item.class]" slot='active-icon' :src='item.imgs'></image>
			</uvtabbarItem>
		</uvtabbar>
	</view>
</template>

<script>
	import uvtabbar from "@/uni_modules/uv-tabbar/components/uv-tabbar/uv-tabbar.vue";
	import uvtabbarItem from "@/uni_modules/uv-tabbar/components/uv-tabbar-item/uv-tabbar-item.vue";
	export default {
		components: {
			uvtabbar,
			uvtabbarItem
		},
		props: ['value'],

		data() {
			return {
				token: '',
				tel: '',
				list: [{
						text: '首页',
						url: '/pages/tabar/index',
						img: require('@/static/img/index_gray.png'),
						imgs: require('@/static/img/index_green.png'),
						class: 'icon'
					},
					{
						text: '党群建设',
						url: '/pages/tabar/jz',
						img: require('@/static/img/classify_gray.png'),
						imgs: require('@/static/img/classify_green.png'),
						class: 'icon'
					},
					{
						text: '学习专题',
						url: '/pages/tabar/zt',
						img: require('@/static/img/classify_gray.png'),
						imgs: require('@/static/img/classify_green.png'),
						class: 'icon'
					},
					/* {
						text: '一键拨号',
						url: '/pages/tabar/classify',
						img: require('@/static/img/classify_gray.png'),
						imgs: require('@/static/img/classify_green.png'),
						class: 'icon'
					}, */

					{
						text: '会员注册',
						url: '/pages/tabar/user',
						img: require('@/static/img/user_gray.png'),
						imgs: require('@/static/img/user_green.png'),
						class: 'icon'
					}
				],
			}
		},
		onShow() {

		},
		created() {
			this.token = uni.getStorageSync('userToken');
			this.$get(this.$api.configLists, {
				name: '咨询热线'
			}, (res) => {
				if (res.data.code == 1) {
					
					this.tel = res.data.data[0].value;

				}
			});

		},
		methods: {
			setTel(phone){
				uni.showModal({
					title: '拨打电话给',
					content: phone,
					showCancel: true,
					confirmText: '拨打',
					success(ress) {
						if (ress.confirm) {
							uni.makePhoneCall({
								phoneNumber: phone,
								success(res) {
									console.log(res);
								},
								error(error){
									console.log(error);
								}
							})
						}
					}
				});
			},
			toUrl(item) {

				if (item.text == '一键拨号') {
					this.setTel(this.tel);

					return;
				}

				uni.switchTab({
					url: item.url
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.div {
		width: 100%;
		height: 100rpx;
		background-color: transparent;
	}

	.bottom {
		width: 100%;
		background: #fff;

	}

	.icons {
		width: 40rpx;
		height: 40rpx;
		margin-bottom: 10rpx;
	}

	.icon {
		width: 55rpx;
		height: 55rpx;
	}
</style>